package test3;

public class GirlFriendTest {
    public static void main(String[] args) {
        GirlFriend[] girlFriend = new GirlFriend[4];
        GirlFriend girlFriend1 = new GirlFriend("申梓煜",18,"跳舞,玩");
        GirlFriend girlFriend2 = new GirlFriend("女朋友2",19,"吃");
        GirlFriend girlFriend3 = new GirlFriend("女朋友3",20,"喝");
        GirlFriend girlFriend4 = new GirlFriend("女朋友4",17,"睡");
        girlFriend[0] = girlFriend1;
        girlFriend[1] = girlFriend2;
        girlFriend[2] = girlFriend3;
        girlFriend[3] = girlFriend4;
        double averageAge=(girlFriend[0].getAge()+girlFriend[1].getAge()+girlFriend[2].getAge()+girlFriend[3].getAge())/4.0;
        System.out.println("四个女朋友的平均年龄是"+averageAge);
        for(GirlFriend g: girlFriend){
            if(g.getAge()<averageAge){
                System.out.println("姓名"+g.getName()+",年龄"+g.getAge()+",爱好"+g.getHobby());
            }
        }
        System.out.println("以上是年龄小于平均年龄的女朋友");
    }
}
